﻿<ComboBox x:Class="Daytimer.Controls.ColorPicker" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
		xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="23"
		d:DesignWidth="100">
	<ComboBox.Style>
		<Style TargetType="ComboBox">
			<Setter Property="BorderThickness" Value="1" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="ComboBox">
						<Grid x:Name="templateRoot" SnapsToDevicePixels="True">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="*" />
								<ColumnDefinition MinWidth="17" Width="0" />
							</Grid.ColumnDefinitions>
							<Popup x:Name="PART_Popup" AllowsTransparency="True" Grid.ColumnSpan="2"
									IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
									PopupAnimation="Fade" Placement="Bottom" HorizontalOffset="-5" VerticalOffset="-6">
								<Popup.Style>
									<Style TargetType="Popup">
										<Setter Property="CacheMode">
											<Setter.Value>
												<BitmapCache />
											</Setter.Value>
										</Setter>
										<Style.Triggers>
											<Trigger Property="IsOpen" Value="True">
												<Trigger.EnterActions>
													<BeginStoryboard>
														<Storyboard>
															<DoubleAnimation Storyboard.TargetProperty="VerticalOffset"
																	From="-20" Duration="0:0:0.3">
																<DoubleAnimation.EasingFunction>
																	<QuarticEase />
																</DoubleAnimation.EasingFunction>
															</DoubleAnimation>
														</Storyboard>
													</BeginStoryboard>
												</Trigger.EnterActions>
											</Trigger>
										</Style.Triggers>
									</Style>
								</Popup.Style>
								<Border MaxHeight="{TemplateBinding MaxDropDownHeight}">
									<Border.Effect>
										<DropShadowEffect Color="#FFBBBBBB" ShadowDepth="0" RenderingBias="Performance"
												Opacity="0.5" />
									</Border.Effect>
									<Border x:Name="DropDownBorder" BorderBrush="#FF828790" BorderThickness="1"
											Background="{DynamicResource White}" Margin="5">
										<ScrollViewer x:Name="DropDownScrollViewer">
											<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
												<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0"
														VerticalAlignment="Top" Width="0">
													<Rectangle x:Name="OpaqueRect"
															Fill="{Binding Background, ElementName=DropDownBorder}"
															Height="{Binding ActualHeight, ElementName=DropDownBorder}"
															Width="{Binding ActualWidth, ElementName=DropDownBorder}" />
												</Canvas>
												<ItemsPresenter x:Name="ItemsPresenter"
														KeyboardNavigation.DirectionalNavigation="Contained"
														SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
											</Grid>
										</ScrollViewer>
									</Border>
								</Border>
							</Popup>
							<ToggleButton x:Name="toggleButton" BorderBrush="{TemplateBinding BorderBrush}"
									BorderThickness="{TemplateBinding BorderThickness}"
									Background="{TemplateBinding Background}" Grid.ColumnSpan="2"
									IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
								<ToggleButton.Style>
									<Style TargetType="ToggleButton">
										<Setter Property="OverridesDefaultStyle" Value="True" />
										<Setter Property="IsTabStop" Value="False" />
										<Setter Property="Focusable" Value="False" />
										<Setter Property="ClickMode" Value="Release" />
										<Setter Property="Template">
											<Setter.Value>
												<ControlTemplate TargetType="ToggleButton">
													<Border x:Name="templateRoot" BorderBrush="#FFACACAC"
															BorderThickness="{TemplateBinding BorderThickness}"
															SnapsToDevicePixels="True"
															Background="{DynamicResource ButtonNormalBackground}">
														<Border x:Name="splitBorder" BorderBrush="Transparent"
																BorderThickness="1" HorizontalAlignment="Right"
																Margin="0" SnapsToDevicePixels="True" Width="17">
															<Path x:Name="Arrow"
																	Data="F1M0,0L2.667,2.66665 5.3334,0 5.3334,-1.78168 2.6667,0.88501 0,-1.78168 0,0z"
																	Fill="#FF606060" HorizontalAlignment="Center"
																	Margin="0,2,0,0" VerticalAlignment="Center" />
														</Border>
													</Border>
													<ControlTemplate.Triggers>
														<MultiDataTrigger>
															<MultiDataTrigger.Conditions>
																<Condition
																		Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType=ComboBox}}"
																		Value="True" />
																<Condition
																		Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
																		Value="False" />
																<Condition
																		Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}"
																		Value="False" />
																<Condition
																		Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}"
																		Value="True" />
															</MultiDataTrigger.Conditions>
															<Setter Property="Background" TargetName="templateRoot"
																	Value="{DynamicResource White}" />
															<Setter Property="BorderBrush" TargetName="templateRoot"
																	Value="#FFABADB3" />
															<Setter Property="Background" TargetName="splitBorder"
																	Value="Transparent" />
															<Setter Property="BorderBrush" TargetName="splitBorder"
																	Value="Transparent" />
														</MultiDataTrigger>
														<Trigger Property="IsMouseOver" Value="True">
															<Setter Property="Fill" TargetName="Arrow" Value="Black" />
														</Trigger>
														<MultiDataTrigger>
															<MultiDataTrigger.Conditions>
																<Condition
																		Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
																		Value="True" />
																<Condition
																		Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType=ComboBox}}"
																		Value="False" />
															</MultiDataTrigger.Conditions>
															<Setter Property="Background" TargetName="templateRoot"
																	Value="{DynamicResource ButtonMouseOverBackground}" />
															<Setter Property="BorderBrush" TargetName="templateRoot"
																	Value="{DynamicResource ButtonMouseOverBorder}" />
														</MultiDataTrigger>
														<MultiDataTrigger>
															<MultiDataTrigger.Conditions>
																<Condition
																		Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
																		Value="True" />
																<Condition
																		Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType=ComboBox}}"
																		Value="True" />
															</MultiDataTrigger.Conditions>
															<Setter Property="Background" TargetName="templateRoot"
																	Value="{DynamicResource White}" />
															<Setter Property="BorderBrush" TargetName="templateRoot"
																	Value="#FF7EB4EA" />
															<Setter Property="Background" TargetName="splitBorder"
																	Value="{DynamicResource ButtonMouseOverBackground}" />
															<Setter Property="BorderBrush" TargetName="splitBorder"
																	Value="{DynamicResource ButtonMouseOverBorder}" />
														</MultiDataTrigger>
														<Trigger Property="IsPressed" Value="True">
															<Setter Property="Fill" TargetName="Arrow" Value="Black" />
														</Trigger>
														<MultiDataTrigger>
															<MultiDataTrigger.Conditions>
																<Condition
																		Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}"
																		Value="True" />
																<Condition
																		Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType=ComboBox}}"
																		Value="False" />
															</MultiDataTrigger.Conditions>
															<Setter Property="Background" TargetName="templateRoot"
																	Value="{DynamicResource ButtonPressedBackground}" />
															<Setter Property="BorderBrush" TargetName="templateRoot"
																	Value="{DynamicResource ButtonPressedBorder}" />
														</MultiDataTrigger>
														<MultiDataTrigger>
															<MultiDataTrigger.Conditions>
																<Condition
																		Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}"
																		Value="True" />
																<Condition
																		Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType=ComboBox}}"
																		Value="True" />
															</MultiDataTrigger.Conditions>
															<Setter Property="Background" TargetName="templateRoot"
																	Value="{DynamicResource White}" />
															<Setter Property="BorderBrush" TargetName="templateRoot"
																	Value="#FF569DE5" />
															<Setter Property="Background" TargetName="splitBorder"
																	Value="{DynamicResource ButtonPressedBackground}" />
															<Setter Property="BorderBrush" TargetName="splitBorder"
																	Value="{DynamicResource ButtonPressedBorder}" />
														</MultiDataTrigger>
														<Trigger Property="IsEnabled" Value="False">
															<Setter Property="Fill" TargetName="Arrow" Value="#FFBFBFBF" />
														</Trigger>
														<MultiDataTrigger>
															<MultiDataTrigger.Conditions>
																<Condition
																		Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}"
																		Value="False" />
																<Condition
																		Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType=ComboBox}}"
																		Value="False" />
															</MultiDataTrigger.Conditions>
															<Setter Property="Background" TargetName="templateRoot"
																	Value="#FFF0F0F0" />
															<Setter Property="BorderBrush" TargetName="templateRoot"
																	Value="#FFD9D9D9" />
														</MultiDataTrigger>
														<MultiDataTrigger>
															<MultiDataTrigger.Conditions>
																<Condition
																		Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}"
																		Value="False" />
																<Condition
																		Binding="{Binding IsEditable, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType=ComboBox}}"
																		Value="True" />
															</MultiDataTrigger.Conditions>
															<Setter Property="Background" TargetName="templateRoot"
																	Value="{DynamicResource White}" />
															<Setter Property="BorderBrush" TargetName="templateRoot"
																	Value="#FFBFBFBF" />
															<Setter Property="Background" TargetName="splitBorder"
																	Value="Transparent" />
															<Setter Property="BorderBrush" TargetName="splitBorder"
																	Value="Transparent" />
														</MultiDataTrigger>
													</ControlTemplate.Triggers>
												</ControlTemplate>
											</Setter.Value>
										</Setter>
									</Style>
								</ToggleButton.Style>
							</ToggleButton>
							<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0"
									IsHitTestVisible="False">
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto" />
									<RowDefinition Height="5" />
								</Grid.RowDefinitions>
								<Image Source="pack://application:,,,/Daytimer.Images;component/Images/colorwheel.png"
										HorizontalAlignment="Center" Stretch="None" />
								<Border Grid.Row="1" Height="5" Width="18" BorderThickness="1"
										BorderBrush="{DynamicResource White}">
									<ContentPresenter x:Name="contentPresenter"
											Content="{TemplateBinding SelectionBoxItem}" IsHitTestVisible="False"
											SnapsToDevicePixels="True" />
								</Border>
							</Grid>
						</Grid>
						<ControlTemplate.Triggers>
							<Trigger Property="IsKeyboardFocusWithin" Value="True">
								<Setter Property="Foreground" Value="Black" />
							</Trigger>
							<Trigger Property="HasItems" Value="False">
								<Setter Property="Height" TargetName="DropDownBorder" Value="95" />
							</Trigger>
							<Trigger Property="CanContentScroll" SourceName="DropDownScrollViewer" Value="False">
								<Setter Property="Canvas.Top" TargetName="OpaqueRect"
										Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}" />
								<Setter Property="Canvas.Left" TargetName="OpaqueRect"
										Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}" />
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</ComboBox.Style>
	<ComboBox.Resources>
		<Style TargetType="ComboBoxItem">
			<Setter Property="BorderBrush" Value="#FFE2E4E7" />
			<Setter Property="HorizontalAlignment" Value="Left" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="ComboBoxItem">
						<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1"
								SnapsToDevicePixels="True">
							<Grid>
								<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"
										Content="{TemplateBinding Content}"
										ContentStringFormat="{TemplateBinding ContentStringFormat}"
										HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
										SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
										VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
								<Border x:Name="InnerBd" BorderThickness="1" BorderBrush="Transparent" />
							</Grid>
						</Border>
						<ControlTemplate.Triggers>
							<Trigger Property="IsEnabled" Value="False">
								<Setter Property="TextElement.Foreground" TargetName="Bd" Value="#FF6D6D6D" />
							</Trigger>
							<MultiTrigger>
								<MultiTrigger.Conditions>
									<Condition Property="IsSelected" Value="False" />
									<Condition Property="IsMouseOver" Value="True" />
								</MultiTrigger.Conditions>
								<Setter Property="BorderBrush" TargetName="Bd" Value="#FFF29436" />
								<Setter Property="BorderBrush" TargetName="InnerBd" Value="#FFFFE294" />
							</MultiTrigger>
							<MultiTrigger>
								<MultiTrigger.Conditions>
									<Condition Property="IsSelected" Value="True" />
									<Condition Property="IsMouseOver" Value="False" />
								</MultiTrigger.Conditions>
								<Setter Property="BorderBrush" TargetName="Bd" Value="#FFEF4810" />
								<Setter Property="BorderBrush" TargetName="InnerBd" Value="#FFFFE294" />
							</MultiTrigger>
							<MultiTrigger>
								<MultiTrigger.Conditions>
									<Condition Property="IsSelected" Value="True" />
									<Condition Property="IsMouseOver" Value="True" />
								</MultiTrigger.Conditions>
								<Setter Property="BorderBrush" TargetName="Bd" Value="#FFF29536" />
								<Setter Property="BorderBrush" TargetName="InnerBd" Value="#FFFFE395" />
							</MultiTrigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style x:Key="Color" TargetType="Border">
			<Setter Property="Width" Value="19" />
			<Setter Property="Height" Value="19" />
			<Setter Property="HorizontalAlignment" Value="Center" />
			<Setter Property="VerticalAlignment" Value="Center" />
		</Style>
	</ComboBox.Resources>
</ComboBox>